<?php

namespace Drupal\shushengyuan\Schemas;

/**
 * @OA\Schema(
 *   schema="SignItem",
 *   type="object",
 *   description="SignItem"
 * )
 */
class SignItem extends AbstractBaseModel {

  protected function getEntityType() {
    return FALSE;
  }

  protected function setValue() {
    [$placeholder, $date] = $this->context;

    $value = [
      /**
       * @OA\Property(
       *   property="placeholder",
       *   type="integer",
       *   description="占位类型 0 空白占位 1 正常签到 2 日期占位",
       * ),
       */
      'placeholder' => (int) $placeholder,
      /**
       * @OA\Property(
       *   property="day",
       *   type="integer",
       *   description="第几天 没有前导零 1 到 31",
       * ),
       */
      'day' => (int) $this->formatDate($date, 'j'),
      /**
       * @OA\Property(
       *   property="today",
       *   type="integer",
       *   description="今日标记 0 否 1 是",
       * ),
       */
      'today' => (int) ($this->formatDate($date, 'j') == $this->formatDate(REQUEST_TIME, 'j')),
    ];
    $this->merge($value);
  }
}
